<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"                  
                xmlns:f="http://java.sun.com/jsf/core"  
                xmlns:p="http://primefaces.org/ui"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./default_template.xhtml">

    <ui:define name="content">
        <f:view rendered="#{userController.utilisateur.typeUser == 'Admin'}">
            <h:form>
                <h1><h:outputText value="Liste des utilisateurs :"/></h1>
                <p:dataTable value="#{userController.allUsers}" var="item" 
                        emptyMessage="Aucun utilisateurs n'a ete trouve." 
                        widgetVar="compteTable"
                        paginator="true"
                        rows="10">
                    <f:facet name="header">  
                        <p:outputPanel>  
                            <h:outputText value="Chercher dans tous les champs:" />  
                            <p:inputText id="globalFilter" onkeyup="compteTable.filter()" style="width:150px" />  
                        </p:outputPanel>  
                    </f:facet>  
                    <p:column id="idColumn" sortBy="#{item.id}" headerText="Id">
                        <h:outputText value="#{item.id}"/>
                    </p:column>
                    <p:column id="loginColumn" filterBy="#{item.login}"   
                                headerText="Login"
                                filterMatchMode="contains">
                        <h:outputText value="#{item.login}"/>
                    </p:column>
                    <p:column id="nomColumn" filterBy="#{item.nom}"   
                                headerText="Nom"
                                filterMatchMode="contains">
                        <h:outputText value="#{item.nom}"/>
                    </p:column>
                    <p:column id="typeColumn" filterBy="#{item.typeUser}"   
                                headerText="Type"
                                filterMatchMode="contains">
                        <h:outputText value="#{item.typeUser}"/>
                    </p:column>
                    <p:column headerText="Action">
                        <h:commandLink class="btn btn-mini btn-primary" style="color: #fff;" action="#{userController.showComptes(item)}" value="Comptes" /> | 
                        <h:commandLink class="btn btn-mini btn-primary" style="color: #fff;" action="#{userController.showComptes(item)}" value="Supprimer" />
                    </p:column>
                </p:dataTable>  
            </h:form>
        </f:view>

    </ui:define>

</ui:composition>
